import org.w3c.dom.ls.LSOutput;
/*
* 创建一个登录平台
* */
public class Test32 {
    public static void main(String[] args) {
        System.out.println("请输入账号和密码");//登录提示
        UserService u =new UserService();//创建登录对象
        //捕捉异常
        try {
            u.register("jackjackjack","123456");
        } catch (UserNameException e) {
            System.out.println(e.getMessage());
        }
    }
}
//登录类
class UserService{
    //登录方法
    public void register(String username,String password) throws UserNameException {
        //用户名长度在6~14之外将会出现异常0
        if (username == null||username.length()<6||username.length()>16) {
            throw new UserNameException("错误，用户名不合法！！！长度应在6~14之间。");
        }
        System.out.println("登录成功，欢迎光临");
    }

}
//自制异常类
class UserNameException extends Exception{
    public UserNameException() {
    }

    public UserNameException(String me) {
        super(me);
    }
}